class Solution():
    def groupAnagrams(self,strs):     
        ans = {}
        for s in strs:
            if tuple(sorted(s)) in ans:
                ans[tuple(sorted(s))].append(s)
            else:
                ans[tuple(sorted(s))] = [s]
        return list(ans.values())
          
               
                
                    

                
